home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 December / PCWorld_2007-12_cd.bin / domacnost a kancelar / autoit / autoit-v3-setup.exe / Examples / Helpfile / _GUICtrlComboAddDir.au3 < prev    next >
Text File  |  2007-09-08  |  3KB  |  73 lines

  1. #include <GuiConstants.au3>
  2. #include <GuiCombo.au3>
  3. #Include <GuiStatusBar.au3>
  4.  
  5. Opt('MustDeclareVars', 1)
  6.  
  7. Dim $a_check[10], $msg, $ret, $s_attr, $allocated, $Status, $GUI
  8. Dim $input, $group, $a_attr, $Combo, $button, $btn_exit
  9.  
  10. $GUI = GUICreate("ComboBox Add Dir", 400, 280)
  11.  
  12. GUICtrlCreateLabel("Enter files to find", 25, 15)
  13. $input = GUICtrlCreateInput("", 125, 10, 180, 25)
  14. $group = GUICtrlCreateGroup("Atrributes", 10, 40, -1, 200)
  15. $a_attr = StringSplit("A,D,H,RO,RW,S,E,Drives,NB", ",")
  16. $a_check[0] = 9
  17. $a_check[1] = GUICtrlCreateCheckbox("Archive", 15, 55, 170, 20)
  18. $a_check[2] = GUICtrlCreateCheckbox("Directory", 15, 75, 170, 20)
  19. $a_check[3] = GUICtrlCreateCheckbox("Hidden", 15, 95, 170, 20)
  20. $a_check[4] = GUICtrlCreateCheckbox("Read-Only", 15, 115, 170, 20)
  21. $a_check[5] = GUICtrlCreateCheckbox("Read-Write", 15, 135, 95, 20)
  22. $a_check[6] = GUICtrlCreateCheckbox("System", 15, 155, 170, 20)
  23. $a_check[7] = GUICtrlCreateCheckbox("Exclusive", 15, 175, 170, 20)
  24. $a_check[8] = GUICtrlCreateCheckbox("Drives", 15, 195, 170, 20)
  25. $a_check[9] = GUICtrlCreateCheckbox("No Brackets (Drives Only)", 15, 215, 170, 20)
  26. GUICtrlCreateGroup("", -99, -99, 1, 1)  ;close group
  27.  
  28. $Combo = GUICtrlCreateCombo("", 240, 40, 120, 120, $CBS_SIMPLE)
  29. $allocated = _GUICtrlComboInitStorage ($Combo, 26, 50)
  30.  
  31. $button = GUICtrlCreateButton("Get Names", 240, 160, 120, 40)
  32. $btn_exit = GUICtrlCreateButton("Exit", 240, 205, 120, 40)
  33.  
  34. $Status = _GUICtrlStatusBarCreate ($GUI, -1, "")
  35. _GUICtrlStatusBarSetSimple ($Status)
  36. _GUICtrlStatusBarSetText ($Status, "Pre-Allocated Memory For: " & $allocated & _
  37.       " Items Added To ComboBox: " & _GUICtrlComboGetCount ($Combo), 255)
  38. GUISetState()
  39. While 1
  40.    $msg = GUIGetMsg()
  41.    Select
  42.       Case $msg = $GUI_EVENT_CLOSE Or $msg = $btn_exit
  43.          ExitLoop
  44.       Case $msg = $button
  45.          $s_attr = ""
  46.          For $i = 1 To $a_check[0]
  47.             If (BitAND(GUICtrlRead($a_check[$i]), $GUI_CHECKED)) Then
  48.                If (StringLen($s_attr) > 0) Then
  49.                   $s_attr &= "," & $a_attr[$i]
  50.                Else
  51.                   $s_attr = $a_attr[$i]
  52.                EndIf
  53.             EndIf
  54.          Next
  55.          _GUICtrlComboResetContent ($Combo)
  56.          $ret = _GUICtrlComboAddDir ($Combo, $s_attr, GUICtrlRead($input))
  57.          If ($ret < 0) Then
  58.             If ($ret == $CB_ERRATTRIBUTE) Then
  59.                MsgBox(16, "Error", "Invalid Attribute sent to _GUICtrlComboAddDir")
  60.             ElseIf ($ret == $CB_ERRSPACE) Then
  61.                MsgBox(16, "Error", "insufficient space to store the new strings from calling _GUICtrlComboAddDir")
  62.             ElseIf ($ret == $CB_ERRREQUIRED) Then
  63.                MsgBox(16, "Error", "Argument required for file search in call to _GUICtrlComboAddDir")
  64.             ElseIf ($ret == $CB_ERR) Then
  65.                MsgBox(16, "Error", "Unknown error from _GUICtrlComboAddDir" & @CRLF & "Possibly no files/folders found")
  66.             EndIf
  67.          EndIf
  68.          _GUICtrlStatusBarSetText ($Status, "Pre-Allocated Memory For: " & $allocated & _
  69.                " Items Added To ComboBox: " & _GUICtrlComboGetCount ($Combo), 255)
  70.    EndSelect
  71. WEnd
  72. Exit
  73.